<template>
    <div class="setinfoy">
        <nav-bar>修改个人性别<template #my> <span @click="cun">保存</span></template></nav-bar>
        <div class="con">
            <van-radio-group v-model="sex">
                <van-cell-group>
                    <van-cell title="男" clickable @click="sex = '0'">
                        <template #right-icon>
                            <van-radio name="0"  checked-color="#ee0a24"/>
                        </template>
                    </van-cell>
                    <van-cell title="女" clickable @click="sex = '1'">
                        <template #right-icon>
                            <van-radio name="1" checked-color="#ee0a24" />
                        </template>
                    </van-cell>
                </van-cell-group>
            </van-radio-group>
        </div>
    </div>
</template>

<script>
import { putUser, getUserInfo } from "../http/login"
export default {
    data() {
        return {
            sex:""
        }
    },
    created() {
        this.getUserInfo()
    },
    methods: {
        async getUserInfo() {
            let res = await getUserInfo()
            this.sex=res.data.sex
        },
        async putUser() {
            let res = await putUser({ sex: this.sex })
            this.$router.push('/info')
        },
        cun() {
            this.putUser()
            
        }
    }
}
</script>

<style lang="scss" scoped>
.con {
    margin-top: 8vh;
}
</style>
